package com.zhuangyuan.cloud.core.models.view;

import com.google.gson.Gson;
import org.springframework.boot.json.GsonJsonParser;

import java.io.Serializable;

public class ActionResult implements Serializable {
    private boolean success;
    private boolean hasError;
    private String errMsg;
    private String redirectUrl;
    public Object data;

    public ActionResult(){}
    public ActionResult(boolean success){this.success = success;}
    public ActionResult(String msg){
        this.success = false;
        this.hasError = true;
        this.errMsg = msg;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public boolean isHasError() {
        return hasError;
    }

    public void setHasError(boolean hasError) {
        this.hasError = hasError;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getRedirectUrl() {
        return redirectUrl;
    }

    public void setRedirectUrl(String redirectUrl) {
        this.redirectUrl = redirectUrl;
    }

    @Override
    public String toString() {
        return new Gson().toJson(this,ActionResult.class);
    }
}
